<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 500px;
            height: 500px;
            background-color: black;
            font-size: 30px;
        }
    </style>
</head>
<body>
    <div>移入改变样式</div>
    <script>
        var box = document.querySelector('div');
        box.onmouseover = function(){
            box.style.backgroundColor='white';
            box.style.border='10px solid red';
        }
        box.onmouseleave = function(){
            box.style.backgroundColor='black';
            box.style.border='0px solid red';
        }
    </script>
</body>
</html>